<?php
/*
	积分排行
*/
defined('BY_JYA') or exit('error');
$return['ischecklogin']=$this->model('member')->checklogin('','','','',true);
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('basic');
	$return['list']=array();
	$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
	$allmember_num=$this->model('member')->getteamids($_SESSION['uid'],1,0,$yuestart);
	$allmember_num=count($allmember_num);
	$return['downnum']=$allmember_num;
	$allmember_num=$this->model('member')->getteamids($_SESSION['uid'],1);
	$allmember_num=count($allmember_num);
	$return['member_num']=$allmember_num;
	$return['teamfee']=pdo_getsum('jy_baojdai_order',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$downmids,'createtime >'=>$yuestart),'order_price');
	$item['rank']=$count+1;
	$return['item']=$item;
	set_html('title','月推荐排名');
	exi($return);
}
// 获取排名数据
if($_RQ['op']=='getlist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'agent_id'=>$_SESSION['uid']);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 300;
	$total='';
	$list=pdo_getslice('jy_baojdai_member',$params,array($pindex,$psize),$total,array(),'','member_num desc,is_agent desc,id desc');
	foreach($list as $k=>&$item){
		$item['member_num']=pdo_count('jy_baojdai_member',array('uniacid'=>$_SESSION['uniacid'],'agent_id'=>$item['mid']));
		if($item['member_num'] && $k>10){
			unset($list[$k]);
			continue;
		}
		$item['member']=cfc('core')->member_show($item['mid']);
	}
	paixu($list,'member_num','desc');
	$return['list']=$list;
	exi($return);
}
?>